package com.ruoyi.zhjd.exp.modules.marshallrequires.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

//import com.qzsoft.zhjd.common.utils.ServiceExceptionUtils;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.zhjd.exp.modules.marshallrequires.dto.MarshallRequiresDto;
import com.ruoyi.zhjd.exp.modules.marshallrequires.entity.MarshallRequiresEntity;
import com.ruoyi.zhjd.exp.modules.marshallrequires.mapper.MarshallRequiresMapper;
import com.ruoyi.zhjd.exp.modules.marshallrequires.service.MarshallRequiresService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author zhaij
 * @Description //马歇尔试验技术要求服务类
 * @Date 13:41 2021\11\26 0026
 * @Param
 * @return
 **/
@Service
public class MarshallRequiresServiceImpl extends ServiceImpl<MarshallRequiresMapper, MarshallRequiresEntity> implements MarshallRequiresService {
//    @Autowired
//    private BaseServiceComponent baseServiceComponent;

    @Override
    public IPage<MarshallRequiresDto> page(Map<String, Object> map) {
        IPage<MarshallRequiresDto> page = null;
        IPage<MarshallRequiresDto> result  = baseMapper.page(page,map);
        return result;
    }

    @Override
    public void saveMarshallRequires(MarshallRequiresEntity entity) {
        QueryWrapper<MarshallRequiresEntity> query = new QueryWrapper<>();
        query.eq("deleted","0").eq("name",entity.getName());
            long size = baseMapper.selectCount(query);
            if(size > 0){
                throw new ServiceException("样品名称已存在，请重新输入！");
            }
            baseMapper.insert(entity);
    }
}
